package entity;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;


public class Taxi {

	public static Map<String, Taxi> taxis = new HashMap<String, Taxi>(); 
	public static enum Status{available,occupied,enroute,offline,pause};
	private Status status;
	private Position position;
	private int taxiID;

	public Taxi(int taxiID, float longitude, float latitude, Calendar time, Status status){
		this.taxiID = taxiID;
		Position newPos = new Position(time, latitude, longitude);
		this.position = newPos;
		this.status = status;
	}

	public static void addTaxi(Taxi taxi){
		taxis.put(Integer.toString(taxi.getTaxiID()), taxi);
	}


	/**
	 * Getter of the property <tt>position</tt>
	 * @return  Returns the position.
	 * @uml.property  name="position"
	 */
	public Position getPosition() {
		return position;
	}

	/**
	 * Setter of the property <tt>position</tt>
	 * @param position  The position to set.
	 * @uml.property  name="position"
	 */
	public void setPosition(Position position) {
		this.position = position;
	}

	public void setStatus(Status status){
		this.status = status;
	}
	
	public Status getStatus(){
		return status;
	}

	public boolean statusChanged(Status status){
		boolean changed = false;
		if(this.status.equals(status)){
			return changed;
		}
		else{
			changed = true;
			return changed;
		}
	}

	/**
	 * @return the taxaid
	 */
	public int getTaxiID() {
		return taxiID;
	}
	
	public static Taxi getTaxi(int taxiID) {
		Taxi taxi = taxis.get(Integer.toString(taxiID));
		return taxi;
		}
}
